﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CooStationsToolsNew
{
    /// <summary>
    /// PageListUC.xaml 的交互逻辑
    /// </summary>
    public partial class PageListUC : UserControl
    {
        //获得页面序号
       public string pageName=null;
       public  Model.CfyPage cfyp;
       Canvas can;
       System.Timers.Timer time=null;
       public bool islive = true;
       Window win = null;
   
        public PageListUC(Model.CfyPage _cfyp,Canvas _can,Window _win)
        {
            InitializeComponent();
            cfyp = _cfyp;
            pageName = _cfyp.PageName;
            can = _can;
            win = _win;
            
        }
       

         bool flag = false;
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            pageName_txt.Text = pageName;
            WorkLeftAreaUC.SaveTheTempList();
            GetBG();
            closebtn.ToolTip = "删除"+pageName;
        }

        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
           
        }
        public void GetBG()
        {
            for (int i = 0; i < App.MiniList.Count; i++)
            {
                //string dd = App.MiniList[i][1].ToString();
                // Object[] obj=App.MiniList[0];
                if (App.MiniList[i][1].ToString() == pageName)
                {

                    ImageSource imgs = App.MiniList[i][0] as ImageSource;
                    ImageBrush ib = new ImageBrush(imgs);
                    ib.Stretch = Stretch.Fill;
                    //pcan.Background = ib;                    
                    rectFill.Fill = ib;
                    rectFill.Width = double.Parse(App.cpage.Width);
                    rectFill.Height = double.Parse(App.cpage.Height);
                    //awCanvas
                    break;
                }
            }
        }
        public void setSize(string _width,string _height)
        {
            rectFill.Width = double.Parse(_width);
            rectFill.Height = double.Parse(_height);
        }

        private void UserControl_MouseEnter(object sender, MouseEventArgs e)
        {
          //  if (pageName == "cfy") {
           //     return;
           // }
          // img.Visibility = Visibility.Visible;
        }

        private void UserControl_MouseLeave(object sender, MouseEventArgs e)
        {
           // img.Visibility = Visibility.Collapsed;
        }

        private void closebtn_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //MessageForm mf = new MessageForm("是否删除" + pageName);
            //mf.Owner = win;
            //if (mf.ShowDialog()==true)
            //{
            //    using (PageTools pt = new PageTools())
            //    {
            //        pt.DeletePage(pageName);
            //        StackPanel sp = this.Parent as StackPanel;
            //        sp.Children.Remove(this);
            //        islive = false;
            //        //win.N
            //    }
            //}
        }
    }
}
